import { Request, Response } from 'express';
import  globalLogger from 'src/middleWare/logger/winston.config'
//const winstonLogger = require('./winston.config')
export function logger(req: Request, res: Response, next: () => any) {
  //console.info(res.res)
  // 组装日志信息
  const logFormat = `\n >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  Request original url: ${req.originalUrl}
  Method: ${req.method}
  IP: ${req.ip}
  Status code: ${res.statusCode}
  Parmas: ${JSON.stringify(req.params)}
  Query: ${JSON.stringify(req.query)}
  Body: ${JSON.stringify(req.body)} >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
`;
// 根据状态码，进行日志类型区分
globalLogger.info(logFormat)
  next();
}